import os
import ssim
#parameters
encode_input_file="600.yuv"

encode_parameters=[{"bitrate":2000000,"preset":"superfast","enc_params":"low_delay=1"},
                   {"bitrate":120000,"preset":"superfast","enc_params":"low_delay=1"},
                   {"bitrate":50000,"preset":"superfast","enc_params":"low_delay=1"}]



encode_ffmpeg_path="/home/lzh/lzh/code/publish_new/seirios_dev/ffmpeg/ffmpeg"


def encode_cmd(encode_input_file,width,height,bitrate,preset,enc_params,out_put_file):

    encode_cmd=encode_ffmpeg_path + " -y " + \
             "-s " + str(width)+"x"+str(height) + " " + \
             "-pixel_format yuv420p "+ \
             "-i " + encode_input_file + " " + \
             "-vcodec h264enc_vpe "+ " " + \
             "-preset "+ preset + " " + \
             "-enc_params  '" +enc_params  + "' "\
             "-b:v " + str(bitrate) + " "+\
             out_put_file

    print(encode_cmd)
    exit_code=os.system(encode_cmd)
    return exit_code

if __name__ == "__main__":
    for parameter in encode_parameters:
        exit_code = encode_cmd(encode_input_file,1920,1080,parameter["bitrate"],parameter["preset"],parameter["enc_params"],"tmp.mp4")
        assert(exit_code == 0)
    
